<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>社交活动平台 - 数据统计</title>
    <style>
        /* 重置样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
            background-color: #f5f7fa;
            color: #333;
            line-height: 1.6;
        }

        /* 容器样式 */
        .container {
            max-width: 480px;
            margin: 0 auto;
            background-color: #fff;
            min-height: 100vh;
        }

        /* 头部导航 */
        .header {
            position: sticky;
            top: 0;
            background-color: white;
            padding: 16px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            z-index: 100;
        }

        .header-content {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .back-btn {
            background: none;
            border: none;
            font-size: 24px;
            cursor: pointer;
            color: #333;
        }

        .header-title {
            font-size: 18px;
            font-weight: bold;
            flex-grow: 1;
            text-align: center;
        }

        .action-btn {
            background: none;
            border: none;
            font-size: 20px;
            cursor: pointer;
            color: #333;
        }

        /* 统计概览区域 */
        .overview-section {
            padding: 24px 16px;
            text-align: center;
            background: linear-gradient(135deg, #45b7d1 0%, #2c8cb9 100%);
            color: white;
        }

        .overview-avatar {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 40px;
            margin: 0 auto 16px;
            border: 3px solid rgba(255, 255, 255, 0.3);
        }

        .overview-name {
            font-size: 20px;
            font-weight: bold;
            margin-bottom: 4px;
        }

        .overview-stats {
            display: flex;
            justify-content: space-around;
            margin-top: 20px;
        }

        .stat-item {
            text-align: center;
        }

        .stat-value {
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 4px;
        }

        .stat-label {
            font-size: 14px;
            opacity: 0.9;
        }

        /* 时间筛选器 */
        .time-filter {
            padding: 16px;
            display: flex;
            justify-content: center;
            gap: 8px;
            background-color: #f9f9f9;
            border-bottom: 1px solid #eee;
        }

        .time-btn {
            padding: 8px 16px;
            border-radius: 20px;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s ease;
            background-color: #f0f0f0;
            color: #666;
        }

        .time-btn.active {
            background: linear-gradient(135deg, #45b7d1 0%, #2c8cb9 100%);
            color: white;
        }

        /* 统计图表区域 */
        .charts-section {
            padding: 20px 16px;
        }

        .chart-container {
            margin-bottom: 30px;
        }

        .chart-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 20px;
            color: #333;
        }

        /* 图表容器 */
        .chart {
            height: 200px;
            background-color: #f9f9f9;
            border-radius: 12px;
            position: relative;
            overflow: hidden;
        }

        /* 柱状图 */
        .bar-chart {
            display: flex;
            align-items: flex-end;
            justify-content: space-around;
            height: 100%;
            padding: 20px 10px 10px;
        }

        .bar {
            width: 30px;
            background: linear-gradient(to top, #45b7d1, #2c8cb9);
            border-radius: 4px 4px 0 0;
            position: relative;
            transition: all 0.3s ease;
        }

        .bar:hover {
            transform: scale(1.05);
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }

        .bar-label {
            position: absolute;
            bottom: -25px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 12px;
            color: #666;
        }

        .bar-value {
            position: absolute;
            top: -25px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 12px;
            font-weight: bold;
            color: #333;
        }

        /* 折线图 */
        .line-chart {
            position: relative;
            height: 100%;
            padding: 20px 10px 10px;
        }

        .line {
            stroke: #ff6b35;
            stroke-width: 3;
            fill: none;
        }

        .point {
            fill: #ff6b35;
            stroke: white;
            stroke-width: 2;
        }

        /* 活动参与统计 */
        .activity-stats {
            margin-top: 20px;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 16px;
            margin-bottom: 30px;
        }

        .stat-card {
            background-color: #f9f9f9;
            border-radius: 12px;
            padding: 16px;
            text-align: center;
        }

        .stat-card-title {
            font-size: 14px;
            color: #666;
            margin-bottom: 8px;
        }

        .stat-card-value {
            font-size: 20px;
            font-weight: bold;
            color: #ff6b35;
        }

        .stat-card-label {
            font-size: 12px;
            color: #999;
        }

        /* 活动类型分布 */
        .activity-types {
            margin-top: 30px;
        }

        .type-item {
            display: flex;
            align-items: center;
            padding: 12px 0;
            border-bottom: 1px solid #eee;
        }

        .type-item:last-child {
            border-bottom: none;
        }

        .type-icon {
            width: 36px;
            height: 36px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 16px;
            font-size: 18px;
        }

        .type-info {
            flex-grow: 1;
        }

        .type-name {
            font-weight: bold;
            margin-bottom: 4px;
        }

        .type-stats {
            display: flex;
            gap: 12px;
            font-size: 14px;
        }

        .type-count {
            color: #ff6b35;
        }

        /* 底部导航 */
        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background-color: white;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: space-around;
            padding: 12px 0;
            z-index: 100;
        }

        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: #9e9e9e;
            font-size: 12px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .nav-item.active {
            color: #ff6b35;
        }

        .nav-icon {
            font-size: 20px;
            margin-bottom: 4px;
        }

        /* 加载动画 */
        .loading {
            text-align: center;
            padding: 40px 20px;
        }

        .spinner {
            width: 36px;
            height: 36px;
            border: 4px solid #f3f3f3;
            border-top: 4px solid #ff6b35;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 0 auto 20px;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* 响应式适配 */
        @media (max-width: 480px) {
            .header-content {
                padding-top: 4px;
            }
            
            .overview-stats {
                flex-direction: column;
                gap: 16px;
            }
            
            .stats-grid {
                grid-template-columns: 1fr;
            }
        }

        /* 动画效果 */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .chart-container {
            animation: fadeInUp 0.6s ease forwards;
        }

        /* 图表颜色 */
        .color-sport { background: linear-gradient(to top, #45b7d1, #2c8cb9); }
        .color-learning { background: linear-gradient(to top, #7b1fa2, #4a148c); }
        .color-social { background: linear-gradient(to top, #388e3c, #1b5e20); }
        .color-food { background: linear-gradient(to top, #f57c00, #e65100); }
        .color-culture { background: linear-gradient(to top, #c2185b, #880e4f); }
        .color-outdoor { background: linear-gradient(to top, #00796b, #004d40); }

        /* 图表类型图标 */
        .icon-sport { color: #2196f3; }
        .icon-learning { color: #7b1fa2; }
        .icon-social { color: #4caf50; }
        .icon-food { color: #ff9800; }
        .icon-culture { color: #e91e63; }
        .icon-outdoor { color: #009688; }

        /* 数据统计卡片 */
        .data-card {
            background-color: #f9f9f9;
            border-radius: 12px;
            padding: 16px;
            margin-bottom: 16px;
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 12px;
        }

        .card-title {
            font-size: 16px;
            font-weight: bold;
        }

        .card-value {
            font-size: 24px;
            font-weight: bold;
            color: #ff6b35;
        }

        .card-description {
            font-size: 14px;
            color: #666;
        }

        /* 进度条 */
        .progress-container {
            height: 8px;
            background-color: #e0e0e0;
            border-radius: 4px;
            margin-top: 8px;
            overflow: hidden;
        }

        .progress-bar {
            height: 100%;
            background: linear-gradient(90deg, #45b7d1, #2c8cb9);
            border-radius: 4px;
        }

        /* 空状态 */
        .empty-state {
            text-align: center;
            padding: 60px 20px;
        }

        .empty-icon {
            font-size: 48px;
            margin-bottom: 20px;
            color: #ccc;
        }

        .empty-title {
            font-size: 16px;
            font-weight: bold;
            margin-bottom: 12px;
            color: #666;
        }

        .empty-description {
            color: #999;
            margin-bottom: 24px;
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 头部导航 -->
        <header class="header">
            <div class="header-content">
                <button class="back-btn" id="backBtn">←</button>
                <div class="header-title">数据统计</div>
                <button class="action-btn" id="refreshBtn">🔄</button>
            </div>
        </header>

        <!-- 统计概览 -->
        <div class="overview-section">
            <div class="overview-avatar">👤</div>
            <div class="overview-name">张小明</div>
            
            <div class="overview-stats">
                <div class="stat-item">
                    <div class="stat-value">24</div>
                    <div class="stat-label">参与活动</div>
                </div>
                <div class="stat-item">
                    <div class="stat-value">8</div>
                    <div class="stat-label">发起活动</div>
                </div>
                <div class="stat-item">
                    <div class="stat-value">12</div>
                    <div class="stat-label">好友数量</div>
                </div>
            </div>
        </div>

        <!-- 时间筛选器 -->
        <div class="time-filter">
            <button class="time-btn active" data-period="week">本周</button>
            <button class="time-btn" data-period="month">本月</button>
            <button class="time-btn" data-period="quarter">本季度</button>
            <button class="time-btn" data-period="year">今年</button>
        </div>

        <!-- 统计图表区域 -->
        <div class="charts-section">
            <!-- 活动参与趋势图 -->
            <div class="chart-container">
                <h3 class="chart-title">活动参与趋势</h3>
                <div class="chart">
                    <div class="bar-chart" id="activityTrendChart">
                        <!-- 柱状图将通过JavaScript动态生成 -->
                    </div>
                </div>
            </div>

            <!-- 活动类型分布图 -->
            <div class="chart-container">
                <h3 class="chart-title">活动类型分布</h3>
                <div class="chart">
                    <svg class="line-chart" viewBox="0 0 300 150">
                        <path class="line" d="M20,130 L60,90 L100,70 L140,85 L180,60 L220,75 L260,40 L300,60" />
                        <circle class="point" cx="20" cy="130" r="4" />
                        <circle class="point" cx="60" cy="90" r="4" />
                        <circle class="point" cx="100" cy="70" r="4" />
                        <circle class="point" cx="140" cy="85" r="4" />
                        <circle class="point" cx="180" cy="60" r="4" />
                        <circle class="point" cx="220" cy="75" r="4" />
                        <circle class="point" cx="260" cy="40" r="4" />
                        <circle class="point" cx="300" cy="60" r="4" />
                    </svg>
                </div>
            </div>

            <!-- 活动参与统计 -->
            <div class="activity-stats">
                <h3 class="chart-title">活动参与统计</h3>
                <div class="stats-grid">
                    <div class="stat-card">
                        <div class="stat-card-title">参与活动次数</div>
                        <div class="stat-card-value">24次</div>
                        <div class="stat-card-label">本月参与18次</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-card-title">发起活动次数</div>
                        <div class="stat-card-value">8次</div>
                        <div class="stat-card-label">本月发起6次</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-card-title">社交影响力</div>
                        <div class="stat-card-value">中等</div>
                        <div class="stat-card-label">活跃度排名前20%</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-card-title">好友互动</div>
                        <div class="stat-card-value">12人</div>
                        <div class="stat-card-label">本月新增3位好友</div>
                    </div>
                </div>
            </div>

            <!-- 活动类型分布 -->
            <div class="activity-types">
                <h3 class="chart-title">活动类型分布</h3>
                <div class="type-item">
                    <div class="type-icon" style="background-color: #e3f2fd; color: #1976d2;">
                        <span class="icon-sport">🏃</span>
                    </div>
                    <div class="type-info">
                        <div class="type-name">运动健身</div>
                        <div class="type-stats">
                            <span>参与: 8次</span>
                            <span class="type-count">33%</span>
                        </div>
                    </div>
                </div>
                
                <div class="type-item">
                    <div class="type-icon" style="background-color: #f3e5f5; color: #7b1fa2;">
                        <span class="icon-learning">📚</span>
                    </div>
                    <div class="type-info">
                        <div class="type-name">学习成长</div>
                        <div class="type-stats">
                            <span>参与: 6次</span>
                            <span class="type-count">25%</span>
                        </div>
                    </div>
                </div>
                
                <div class="type-item">
                    <div class="type-icon" style="background-color: #e8f5e9; color: #388e3c;">
                        <span class="icon-social">👥</span>
                    </div>
                    <div class="type-info">
                        <div class="type-name">社交互动</div>
                        <div class="type-stats">
                            <span>参与: 5次</span>
                            <span class="type-count">21%</span>
                        </div>
                    </div>
                </div>
                
                <div class="type-item">
                    <div class="type-icon" style="background-color: #fff3e0; color: #f57c00;">
                        <span class="icon-food">🍽️</span>
                    </div>
                    <div class="type-info">
                        <div class="type-name">美食文化</div>
                        <div class="type-stats">
                            <span>参与: 3次</span>
                            <span class="type-count">12%</span>
                        </div>
                    </div>
                </div>
                
                <div class="type-item">
                    <div class="type-icon" style="background-color: #fce4ec; color: #c2185b;">
                        <span class="icon-culture">🎭</span>
                    </div>
                    <div class="type-info">
                        <div class="type-name">文化娱乐</div>
                        <div class="type-stats">
                            <span>参与: 2次</span>
                            <span class="type-count">8%</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 底部导航 -->
        <nav class="bottom-nav">
            <div class="nav-item" data-page="home">
                <span class="nav-icon">🏠</span>
                <span>首页</span>
            </div>
            <div class="nav-item" data-page="search">
                <span class="nav-icon">🔍</span>
                <span>搜索</span>
            </div>
            <div class="nav-item" data-page="publish">
                <span class="nav-icon">➕</span>
                <span>发布</span>
            </div>
            <div class="nav-item active" data-page="profile">
                <span class="nav-icon">👤</span>
                <span>我的</span>
            </div>
        </nav>

        <!-- 加载状态 -->
        <div class="loading" id="loadingIndicator">
            <div class="spinner"></div>
            <p>加载统计数据...</p>
        </div>

        <!-- 通知 Toast -->
        <div id="toast" style="display: none; position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background-color: #4caf50; color: white; padding: 12px 24px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 1001;"></div>
    </div>

    <script>
        // 全局变量
        let currentPeriod = 'week';
        let activityData = {
            week: [12, 8, 15, 6, 10, 9, 14],
            month: [25, 30, 28, 35, 42, 38, 45, 39, 41, 37, 40, 36, 33, 28, 31, 29, 34, 37, 40, 38, 42, 45, 41, 39],
            quarter: [80, 92, 75, 88, 95, 82, 87, 90, 85, 93, 88, 91],
            year: [60, 75, 82, 78, 90, 85, 92, 88, 95, 87, 93, 89]
        };

        // 初始化
        document.addEventListener('DOMContentLoaded', function() {
            initEventListeners();
            simulateLoading();
            
            // 初始化图表
            setTimeout(() => {
                renderActivityTrendChart(currentPeriod);
                hideLoading();
            }, 1500);
        });

        // 初始化事件监听器
        function initEventListeners() {
            // 返回按钮
            document.getElementById('backBtn').addEventListener('click', function() {
                window.history.back();
            });

            // 刷新按钮
            document.getElementById('refreshBtn').addEventListener('click', function() {
                showSuccessToast('正在刷新统计数据...');
                simulateLoading();
                
                setTimeout(() => {
                    hideLoading();
                    showSuccessToast('数据已更新');
                    
                    // 重新渲染图表
                    renderActivityTrendChart(currentPeriod);
                }, 1500);
            });

            // 底部导航切换
            const navItems = document.querySelectorAll('.nav-item');
            navItems.forEach(item => {
                item.addEventListener('click', function() {
                    // 移除所有激活状态
                    navItems.forEach(i => i.classList.remove('active'));
                    // 添加当前激活状态
                    this.classList.add('active');
                    
                    const page = this.dataset.page;
                    handleNavigation(page);
                });
            });

            // 时间筛选器
            const timeButtons = document.querySelectorAll('.time-btn');
            timeButtons.forEach(button => {
                button.addEventListener('click', function() {
                    // 移除所有激活状态
                    timeButtons.forEach(b => b.classList.remove('active'));
                    // 添加当前激活状态
                    this.classList.add('active');
                    
                    currentPeriod = this.dataset.period;
                    renderActivityTrendChart(currentPeriod);
                });
            });

            // 模拟数据更新
            setInterval(() => {
                updateChartData();
            }, 30000); // 每30秒更新一次
        }

        // 渲染活动趋势图表
        function renderActivityTrendChart(period) {
            const chartContainer = document.getElementById('activityTrendChart');
            if (!chartContainer) return;
            
            // 清空现有图表
            chartContainer.innerHTML = '';
            
            const data = activityData[period] || [10, 15, 8, 12, 18, 14, 20];
            const maxValue = Math.max(...data);
            
            data.forEach((value, index) => {
                const barHeight = (value / maxValue) * 150;
                
                const bar = document.createElement('div');
                bar.className = 'bar';
                bar.style.height = `${barHeight}px`;
                bar.style.width = '30px';
                
                // 添加值标签
                const valueLabel = document.createElement('div');
                valueLabel.className = 'bar-value';
                valueLabel.textContent = value;
                
                // 添加标签
                const label = document.createElement('div');
                label.className = 'bar-label';
                
                if (period === 'week') {
                    const days = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
                    label.textContent = days[index];
                } else if (period === 'month') {
                    const months = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', 
                                  '8月', '9月', '10月', '11月', '12月'];
                    label.textContent = months[index];
                } else if (period === 'quarter') {
                    const quarters = ['Q1', 'Q2', 'Q3', 'Q4'];
                    label.textContent = quarters[index];
                } else {
                    const years = ['2023', '2024'];
                    label.textContent = years[index];
                }
                
                bar.appendChild(valueLabel);
                bar.appendChild(label);
                chartContainer.appendChild(bar);
            });
        }

        // 更新图表数据
        function updateChartData() {
            // 模拟数据更新（实际应用中会从API获取）
            const newData = activityData[currentPeriod];
            if (newData && newData.length > 0) {
                // 随机更新数据
                const randomIndex = Math.floor(Math.random() * newData.length);
                newData[randomIndex] = Math.max(1, newData[randomIndex] + (Math.random() > 0.5 ? 1 : -1));
                
                // 重新渲染图表
                renderActivityTrendChart(currentPeriod);
            }
        }

        // 处理导航切换
        function handleNavigation(page) {
            switch(page) {
                case 'home':
                    alert('跳转到首页');
                    break;
                case 'search':
                    alert('跳转到搜索页面');
                    break;
                case 'publish':
                    alert('跳转到发布页面');
                    break;
                case 'profile':
                    // 个人中心无需特殊处理
                    break;
            }
        }

        // 显示加载状态
        function showLoading() {
            const loading = document.getElementById('loadingIndicator');
            loading.style.display = 'block';
        }

        // 隐藏加载状态
        function hideLoading() {
            const loading = document.getElementById('loadingIndicator');
            loading.style.display = 'none';
        }

        // 模拟加载效果
        function simulateLoading() {
            showLoading();
            setTimeout(() => {
                hideLoading();
            }, 1500);
        }

        // 显示成功提示
        function showSuccessToast(message) {
            const toast = document.getElementById('toast');
            toast.textContent = message;
            toast.style.display = 'block';
            
            // 3秒后自动隐藏
            setTimeout(() => {
                toast.style.display = 'none';
            }, 3000);
        }

        // 添加触摸反馈效果
        const buttons = document.querySelectorAll('button, .time-btn');
        buttons.forEach(button => {
            button.addEventListener('touchstart', function() {
                this.style.transform = 'scale(0.95)';
            });
            
            button.addEventListener('touchend', function() {
                this.style.transform = 'scale(1)';
            });
        });

        // 添加页面滚动效果
        let lastScrollTop = 0;
        window.addEventListener('scroll', function() {
            const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
            
            // 隐藏/显示底部导航
            const bottomNav = document.querySelector('.bottom-nav');
            if (scrollTop > lastScrollTop && scrollTop > 100) {
                bottomNav.style.transform = 'translateY(100%)';
            } else {
                bottomNav.style.transform = 'translateY(0)';
            }
            
            lastScrollTop = scrollTop;
        });

        // 添加返回顶部功能
        window.addEventListener('scroll', function() {
            if (window.pageYOffset > 300) {
                // 可以添加返回顶部按钮
            }
        });
    </script>
</body>
</html>
